/**
 * 
 */
package com.taobao.wolfwolf.hibernate.dao.impl;

import java.util.List;

import com.taobao.wolfwolf.hibernate.dao.UnitDao;
import com.taobao.wolfwolf.hibernate.pojo.Unit;

/**
 * @author Tux
 *
 * 创建时间: 2011-5-13 上午08:34:03
 */
@SuppressWarnings("unchecked")
public class UnitDaoImpl extends BaseDaoImpl implements UnitDao {

	public Unit findById(int id) throws Exception {
		return (Unit) getHibernateTemplate().get(Unit.class, id);
	}
	
	public List<Unit> findByName(String name) throws Exception {
		return super.findByProperty(Unit.class, "name", name);
	}

	public List<Unit> findAll() throws Exception {
		return getHibernateTemplate().find("from Unit");
	}

	public long getTotal() throws Exception {
		return super.countByCriteria(Unit.class);
	}

	public List<Unit> paging(int page, int limit) throws Exception {
		return super.findByCriteriaByPage(Unit.class, page, limit);
	}
}
